﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using vkMessengerApp.Core.Networking;

namespace vkMessengerApp.Managers
{
    public class UserManager
    {
        public static void Login(string username, string password)
        {
            HttpWebRequest request = WebRequest.CreateHttp(VkontakteApi.AuthorizationUrl(username, password));

            request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
        }

        private static void ReadWebRequestCallback(IAsyncResult callbackResult)
        {
            HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);

            using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
            {
                string results = httpwebStreamReader.ReadToEnd();
                //Parse result!!!!
            }
            myResponse.Close();
        }
        
    }
}
